﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ART.Common;

namespace ART.Admini.Controls
{
    public partial class _SchoolDialog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }

        private void BindList()
        {
            StringBuilder builder = new StringBuilder(" 1=1 ");
            if (!string.IsNullOrEmpty(this.SchoolName))
            {
                builder.Append(string.Format(" and SchoolName like '%{0}%'", this.SchoolName));
            }

            rptCustomer.PageLink = string.Format("_SchoolDialog.aspx?hidCtl={0}&txtCtl={1}&SchoolName={2}", base.Request.QueryString["txtName"], base.Request.QueryString["hidId"], SchoolName);
            rptCustomer.PageSize = 10;
            rptCustomer.CurrentPage = LYRequest.GetInt("page", 1);

            DataSet ds = BLL.GetListByPage.GetDataSet_NoCache("SchoolDic", "id,SchoolName", builder.ToString(), "", "ID DESC", "ID", rptCustomer.CurrentPage, rptCustomer.PageSize, 1);

            rptCustomer.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            JBind.BindList(rptCustomer, ds.Tables[1]);
        }

        private string SchoolName
        {
            get
            {
                if (!string.IsNullOrEmpty(base.Request.QueryString["SchoolName"]))
                {
                    string text1 = base.Request.QueryString["SchoolName"];
                    this.txtSearch.Text = base.Request.QueryString["SchoolName"];
                }
                return base.Request.QueryString["SchoolName"];
            }
        }
        protected void btnSearch_Click(object sender, EventArgs p1)
        {
            base.Response.Redirect(string.Format("_SchoolDialog.aspx?hidCtl={0}&txtCtl={1}&SchoolName={2}", base.Request.QueryString["txtName"], base.Request.QueryString["hidId"], this.txtSearch.Text));
        }
    }
}
